package com.example.mntz.service.Impl;

import com.example.mntz.dao.WorldListMapper;
import com.example.mntz.model.LayuiTable;
import com.example.mntz.model.TreeLayui;
import com.example.mntz.model.User;
import com.example.mntz.model.Zh;
import com.example.mntz.service.WorldListService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class WorldListServiceImpl implements WorldListService {
    @Autowired
    WorldListMapper mapper;

    public List<TreeLayui> selectcg(){
        /*常规*/
        List<TreeLayui> l1 =  mapper.selectCg(1);
        TreeLayui lC = new TreeLayui();
        lC.setChildren(l1);
        lC.setTitle("常规");
        /*特殊*/
        List<TreeLayui> l2 =  mapper.selectCg(0);
        TreeLayui lT = new TreeLayui();
        lT.setChildren(l1);
        lT.setTitle("特殊");
        List<TreeLayui> layuis = new ArrayList<>();
        layuis.add(lC);
        layuis.add(lT);
        return layuis;
    }

    @Override
    public LayuiTable selectPmList(List<Integer> zqId,Integer page,Integer limit,Integer uId) {
        Page page1 = PageHelper.startPage(page, limit);;
        List<Zh> zhs = mapper.selectUserZhTop(zqId,uId);

        LayuiTable<Zh> layuiTable = new LayuiTable<>();
        layuiTable.setData(zhs);
        layuiTable.setCount(page1.getTotal());
        return layuiTable;
    }
}
